//{=======================================================================
//! @file B2.c
//! @date 05.10.2013 02.:49
//! @author Andrey Drobyshev <immortalguardian1@gmail.com>
//! @ version 1.0
//!
//! @par	Conditions:
//! 		The program reads the number and prints it
//!         	as (b * sqrt (a)), where b is as big as possible.
//}=======================================================================

#include <stdio.h>
#include <math.h>

#define ISITNATURAL(c)  (ceil (c) == c)

//{==============================================================
//! Function main - prints welcome messages and the result,
//! controls all the program execution.
//!
//! @return     0 on success
//}===============================================================

int main ()
{
    printf ( "#Hello!\n"
             "#This program represents a natural number"
             " as (b * sqrt (a)), where b is as big as possible.\n"
             "#Please enter your number: ");
    printf ("\n");

    unsigned int n = 0; // Original number

    scanf ( "%u", &n);

    double c = 0;
    unsigned int a = 0, b = 0;

    for ( a = 1; a <= n / 2; a++)
        if ( !( n % a))             // Check out original number's dividers
        {
            c = sqrt ( n / a);
            if ( ISITNATURAL (c))
            {
                printf ( "sqrt ( %u) = %.0f * sqrt ( %.0f)\n", n, c, n / ( c * c));
                return 0;
            }
        }
    printf ( "sqrt ( %u) = 1 * sqrt (% d)\n", n, n);
    return 0;
}


